<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="js/jquery/jquery-1.7.1.js"></script>
    <link href="css/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="css/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/authority/commonAll.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.fancybox-1.3.4.css" media="screen"></link>
    <script type="text/javascript" src="js/artDialog/artDialog.js?skin=default"></script>
    <title>易居后台管理</title>
    <script type="text/javascript">
        $(document).ready(function(){
            /** 新增   **/
            $("#addBtn").fancybox({
                'href'  : 'sys_insertagent',
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_agent';
                }
            });

            /** 取消 **/
            $("#cancelbutton").click(function() {
                /**  关闭弹出iframe  **/
                window.parent.$.fancybox.close();
            });


            /**编辑   **/
            $("a.edit").fancybox({
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_agent';
                }
            });
        });

        /** 首页尾页跳转 **/
        function jumpPage(page){
            var form = document.getElementById("submitForm");
            if (page != 1) {
                document.getElementById("submitForm").action='/sys_agent?page=' + '[[${pageDTO.page.getPages()}]]';
            }
            else{
                document.getElementById("submitForm").action='/sys_agent?page=' + 1;
            }
            form.submit();
        }
        /** 下一页 **/
        function nextPage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_agent?page=' + '[[${pageDTO.page.getCurrent()+1}]]';
            form.submit();
        }
        /** 首页尾页跳转 **/
        function prePage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_agent?page=' + '[[${pageDTO.page.getCurrent()-1}]]';
            form.submit();
        }

        /** 输入页跳转 **/
        function jumpInputPage(totalPage){
            // 如果“跳转页数”不为空
            if($("#jumpNumTxt").val() != ''){
                var pageNum = parseInt($("#jumpNumTxt").val());
                // 如果跳转页数在不合理范围内，则置为1
                if(pageNum<1 | pageNum>totalPage){
                    art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请输入合适的页数，\n自动为您跳到首页', ok:true,});
                    pageNum = 1;
                }
                $("#submitForm").attr("action", "house_list.html?page=" + pageNum).submit();
            }else{
                // “跳转页数”为空
                art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请输入合适的页数，\n自动为您跳到首页', ok:true,});
                $("#submitForm").attr("action", "house_list.html?page=" + 1).submit();
            }
        }
    </script>
    <style type="text/css">
        .alt td{ background:black !important;}
        li{
            text-decoration: none;  /*去掉前面的圆点*/
            list-style: none;
            float: left;
        }
    </style>
</head>
<body>
<form id="submitForm" name="submitForm" action="/sys_agent" th:action="@{/sys_agent}" method="post">
    <input type="hidden" name="allIDCheck" value="" id="allIDCheck"/>
    <input type="hidden" name="fangyuanEntity.fyXqName" value="" id="fyXqName"/>
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                   <div id="box_top">
                        共有经纪人&nbsp;&nbsp;</b><span th:text="${pageDTO.page.getTotal()}">1000</span><b>人
                   </div>
                    <div id="box_center">
                        评分
                        <select name="rank" id="rank" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="4-5" selected="selected" th:if="${select.rankContain('4-5')}">4-5</option>
                            <option value="4-5" th:unless="${select.rankContain('4-5')}">4-5</option>
                            <option value="3-4" selected="selected" th:if="${select.rankContain('3-4')}">3-4</option>
                            <option value="3-4" th:unless="${select.rankContain('3-4')}">3-4</option>
                            <option value="2-3" selected="selected" th:if="${select.rankContain('2-3')}">2-3</option>
                            <option value="2-3" th:unless="${select.rankContain('2-3')}">2-3</option>
                            <option value="1-2" selected="selected" th:if="${select.rankContain('1-2')}">1-2</option>
                            <option value="1-2" th:unless="${select.rankContain('1-2')}">1-2</option>
                        </select>
                        所属城市
                        <select name="city" id="city" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="成都" selected="selected" th:if="${select.cityContain('成都')}">成都</option>
                            <option value="成都" th:unless="${select.cityContain('成都')}">成都</option>
                            <option value="广州" selected="selected" th:if="${select.cityContain('广州')}">广州</option>
                            <option value="广州" th:unless="${select.cityContain('广州')}">广州</option>
                        </select>
                        审核状态
                        <select name="status" id="status" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="0" selected="selected" th:if="${select.statusContain('0')}">待审核</option>
                            <option value="0" th:unless="${select.statusContain('0')}">待审核</option>
                            <option value="1" selected="selected" th:if="${select.statusContain('1')}">通过</option>
                            <option value="1" th:unless="${select.statusContain('1')}">通过</option>
                        </select>
                    </div>
                    <div id="box_bottom">
                        <input type="submit" value="查询" class="ui_input_btn01"/>
                        <input type="button" value="新增" class="ui_input_btn01" id="addBtn" />
                        <input type="button" value="删除" class="ui_input_btn01" onclick="batchDel();" />
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <th>名字</th>
                        <th>性别</th>
                        <th>电话</th>
                        <th>email</th>
                        <th>所在地区</th>
                        <th>注册时间</th>
                        <th>工作时间</th>
                        <th>所属门店</th>
                        <th>评价分数</th>
                        <th>审核状态</th>
                        <th>操作</th>
                    </tr>
                   <div th:each="agent : ${pageDTO.result}" class="row">
                      <tr>
                        <td style="color: black; text-decoration: none; font-weight: bold" href="#4"
                            th:href="@{'/agent_detail?agentId='+${agent.agentId}}"
                            th:text="${agent.agentName}">杨凯</td>
                        <td th:text="男" th:if="${agent.sex}">nan</td>
                        <td th:text="女" th:unless="${agent.sex}">nv</td>
                        <td th:text="${agent.telephone}">4008959600</td>
                        <td th:text="${agent.email}">77@qq.com</td>
                        <td th:text="${agent.city}">GZ</td>
                        <td th:text="${agent.createTime}">2018-0809<</td>
                        <td th:text="${agent.workingTime+'年'}">3年<</td>
                        <td th:text="${agent.belongShop}">三千里店</td>
                        <td th:text="${agent.rank}">5.0<</td>
                          <td th:text="通过" th:if="${agent.status}"></td>
                          <td th:text="待审核" th:unless="${agent.status}"></td>
                        <td>
                            <a th:if="${agent.status}" th:href="@{'/status_sysagent?agentId=' + ${agent.agentId} + '&status='+${agent.status}}"
                               class="btn btn-default">重新审核</a>
                            <a th:unless="${agent.status}" th:href="@{'/status_sysagent?agentId=' + ${agent.agentId} + '&status='+${agent.status}}"
                               class="btn btn-default">通过审核</a>
                            <!--<a th:href="@{'/sys_deleteagent?agentId=' + ${agent.agentId}}">删除</a>-->
                            <a  class="btn btn-default" onclick="delet(this)" th:value="${agent.agentId}">删除</a>
                        </td>
                    </tr>
                  </div>
                </table>
            </div>
        </div>
    </div>
</form>
<script>
    function delet(sender) {
        var msg=confirm("确定删除？");    //弹出一个窗口，询问客户信息，然后返回boolean值
        if(msg == true){
            $(document).ready(function(){
                $.ajax({
                    type:"GET",
                    url:"/sys_deleteagent?agentId="+$(sender).attr("value"),
                    async:false,
                    success:function (data) {
                        alert("删除成功");
                        location.reload();
                    },
                    error:function (jqXHR) {
                        alert("删除失败");
                    }
                });
            });
        }
        else  {
        }
    }
</script>
<!-- 分页条 -->
 <div class="container">
     <div class="row">
        <nav style="text-align: left" aria-label="Page navigation">
            <ul class="pagination">
                <li ><a style="color: black" th:text="' 第 '+${pageDTO.page.getCurrent()}+' 页/共 '+${pageDTO.page.getPages()}+' 页 '"/></li>
                <li>
                    <button onclick="jumpPage(1)">首页</button>
                </li>
                <li th:if="${pageDTO.page.hasPrevious()}">
                    <button aria-label="Previous" onclick="prePage()">上一页</button>
                </li>
                <li th:if="${pageDTO.page.hasNext()}">
                    <button aria-label="Next" onclick="nextPage()">下一页</button>
                </li>
                <li>
                    <button onclick="jumpPage(0)">尾页</button>
                </li>
                <li><input type="button" id="cancelbutton"   value="关闭" /></li>
            </ul>
        </nav>
     </div>
 </div>
</body>
</html>
